<template>
  <div class="app-container">
    <el-row :gutter="10" class="mb8">
      <!-- 添加或修改【请填写功能名称】对话框 -->
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          size="mini"
          @click="getContractList"
          v-hasPermi="['account:day:list']"
        >查询合同</el-button>
      </el-col>
<br>

      <el-form ref="form" :model="form" :rules="rules" label-width="100px">

        <el-form-item label="收房合同号" prop="contractNo">
          <el-input v-model="form.contractNo" placeholder="请输入收房合同号" />
        </el-form-item>
        <el-form-item label="房产信息" prop="premiseName">
          <el-input v-model="form.premiseName" placeholder="房产信息" />
        </el-form-item>
        <el-form-item label="业主姓名" prop="ownerName">
          <el-input v-model="form.ownerName" placeholder="请输入业主姓名" />
        </el-form-item>
        <el-button type="primary" @click="subotherItemName">新增款项</el-button>
        <br>
        是否付款:<template>
          <el-radio v-model="radio" label="1">已付</el-radio>
          <el-radio v-model="radio" label="2">未付</el-radio>
        </template>



        <el-form-item label="选择账期" prop="withPayPlanId">
          <el-input v-model="form.withPayPlanId" placeholder="请输入选择账期" />
        </el-form-item>
        <el-form-item label="账期开始日" prop="paymentDaysBegin">
          <el-date-picker clearable
                          v-model="form.paymentDaysBegin"
                          type="date"
                          value-format="yyyy-MM-dd"
                          placeholder="请选择账期开始日">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item>

        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              @click="handleClick(scope.row)"
            >选中</el-button>
          </template>
        </el-table-column>

        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </el-form>

    </el-row>
  </div>
</template>

<script>
import { listPlan, getPlan, delPlan, addPlan, updatePlan } from "@/api/account/plan";
import {listContract} from "@/api/contract/contract";

export default {
  name: "Plan",
  data() {
    return {
      radio: '1',
      // 遮罩层
      loading: true,

      dialogTableVisible: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      planList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        payOrderNo: null,
        businessId: null,
        contractId: null,
        contractNo: null,
        contractType: null,
        tTerminationId: null,
        premiseId: null,
        premiseName: null,
        ownerId: null,
        ownerName: null,
        tenantId: null,
        tenantName: null,
        payType: null,
        payState: null,
        billType: null,
        itemType: null,
        otherItemName: null,
        paymentAmount: null,
        realPaymentAmount: null,
        withPayPlanId: null,
        paymentDaysBegin: null,
        paymentDaysEnd: null,
        payableDate: null,
        paidTime: null,
        payNumber: null,
        payMethod: null,
        otherPayMethod: null,
        payFlowNo: null,
        rentalPrice: null,
        tax: null,
        operationUser: null,
        totalPayNumber: null,
        repayType: null,
        delFlg: null,
        createUserid: null,
        updateUserid: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        payOrderNo: [
          { required: true, message: "付款单号不能为空", trigger: "blur" }
        ],
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {

/*    handleClick(row){
      this.form.businessId=row.businessId
      this.dialogTableVisible=false;
    },*/

    getContractList() {
      this.loading = true
      listContract(this.queryParams).then(response => {
        this.contractList = response.rows
        this.total = response.total
        this.loading = false
        this.dialogTableVisible=true;
      })
    },

    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      listPlan(this.queryParams).then(response => {
        this.planList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        payOrderNo: null,
        businessId: null,
        contractId: null,
        contractNo: null,
        contractType: null,
        tTerminationId: null,
        premiseId: null,
        premiseName: null,
        ownerId: null,
        ownerName: null,
        tenantId: null,
        tenantName: null,
        payType: null,
        payState: null,
        billType: null,
        itemType: null,
        otherItemName: null,
        paymentAmount: null,
        realPaymentAmount: null,
        withPayPlanId: null,
        paymentDaysBegin: null,
        paymentDaysEnd: null,
        payableDate: null,
        paidTime: null,
        payNumber: null,
        payMethod: null,
        otherPayMethod: null,
        payFlowNo: null,
        rentalPrice: null,
        tax: null,
        operationUser: null,
        totalPayNumber: null,
        repayType: null,
        remark: null,
        delFlg: null,
        createUserid: null,
        createTime: null,
        updateUserid: null,
        updateTime: null
      };
      this.resetForm("form");
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          addPlan(this.form).then(response => {
            this.$modal.msgSuccess("新增成功");
            this.open = false;
            this.getList();
          });
        }
      });
    },
  }
};
</script>
